﻿using Magicodes.ExporterAndImporter.Excel.AspNetCore;
using Magicodes.ExporterAndImporter.Excel;
using Microsoft.AspNetCore.Mvc;
using NP.BPMReportPlatform.Reports.YHSQ.Dtos;
using NP.BPMReportPlatform.Reports.YHSQ;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Microsoft.AspNetCore.Authorization;
using NP.BPMReportPlatform.Reports.DailyCloseBook.Dtos;

namespace NP.BPMReportPlatform.Reports.DailyCloseBook
{
    [Authorize]
    [ApiController]
    [Route("api/Reports/DailyCloseBook")]
    public class DailyCloseBookController : BPMReportPlatformController
    {
        private readonly IDailyCloseBookService _service;
        private readonly IExcelImporter _importer;
        public DailyCloseBookController(
            IDailyCloseBookService service,
            IExcelImporter importer)
        {
            _service = service;
            _importer = importer;
        }

        /// <summary>
        /// 要货申请报表查询
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("GetAllAsync")]
        public async Task<PagedResultDto<GetDailyCloseBookOutput>> GetAllAsync([FromBody] DailyCloseBookInput input)
        {
            return await _service.GetAllAsync(input);
        }

        /// <summary>
        /// 要货申请报表导出
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("ExportExcel")]
        public async Task<XlsxFileResult<GetDailyCloseBookOutput>> ExportExcel([FromBody] DailyCloseBookInput input)
        {
            var rst = await _service.ExportAsync(input);
            return new XlsxFileResult<GetDailyCloseBookOutput>(rst, "导出Excel");
        }
    }
}
